package com.yang.biz.modular.xssf.util;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;

/**
 * @author: yangjianzhi
 * @version1.0
 */
public class ToolUtil {

    /**
     * 格式化单元格值作为字符串
     *
     * @param cell
     * @return
     */
    private String getStringCellValue(Cell cell) {
        DataFormatter dataFormatter = new DataFormatter();
        return dataFormatter.formatCellValue(cell);
    }

    /**
     * 根据cell value获取指标类型
     */
    private String getMeasureType(Cell cell) {
        String type = "";
        try {
            CellType cellType = cell.getCellType();
            switch (cellType) {
                case NUMERIC:
                    // 不考虑，整型情况
                    type = "DOUBLE";
                    break;
                case BOOLEAN:
                    type = "BOOLEAN";
                    break;
                case STRING:
                default:
                    type = "STRING";
                    break;
            }
        } catch (Exception ignored) {
            type = "STRING";
        }
        return type;
    }
}
